#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

#define THREADNUM 10

int indexs = 0;

void *thread_func(void *arg)
{
  for (int i = 0; i < 10000000; i++) {
    indexs++;
  }
  pthread_exit(NULL);
}

int main()
{
  pthread_t thread_ids[THREADNUM] = {0};
  int err;
  for (int i = 0; i < THREADNUM; i++) {
    err = pthread_create(thread_ids + i, NULL, thread_func, NULL);
    if (err) {
      fprintf(stderr, "pthread_create");
      exit(1);
    }
  }

  for (int i = 0; i < THREADNUM; i++) {
    if (thread_ids[i] != 0) {
      pthread_join(thread_ids[i], NULL);
    }
  }

  printf("%d\n", indexs);
  exit(0);
}
